package itsm.isperp.module.service.configuration;

import itsm.isperp.framework.service.BaseService;
import itsm.isperp.module.dto.configuration.ConfCiPropertyDTO;
import itsm.isperp.module.entity.configuration.ConfCiProperty;
import itsm.isperp.module.repository.configuration.ConfCiPropertyMapper;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

/**
 * 配置项属性服务
 * 
 * @author lizx
 * @date 2013-4-29
 */
@Service
public class ConfCiPropertyService extends BaseService<ConfCiProperty> {

	@Autowired
	ConfCiPropertyMapper confCiPropertyMapper;
	@Autowired
	JdbcTemplate jdbcTemplate;

	@Override
	public ConfCiPropertyMapper getRepository() {
		return confCiPropertyMapper;
	}

	public List<ConfCiProperty> findByCiId(String ciId) {
		return confCiPropertyMapper.findByCiId(ciId);
	}

	public void deleteByCiId(String ciId) {
		confCiPropertyMapper.deleteByCiId(ciId);
	}

	public ConfCiProperty findByCiIdAndPropertyId(String ciId, String propertyId) {
		return confCiPropertyMapper.findByCiIdAndPropertyId(ciId, propertyId);
	}

	public List<ConfCiProperty> findByCiIdAndPropertyIds(String ciId,
			String... propertyIds) {
		return confCiPropertyMapper.findByCiIdAndPropertyIds(ciId, propertyIds);
	}

	public List<ConfCiProperty> findByCiIdsAndPropetyId(String[] ciIdArr,
			String propertyId) {
		if (ciIdArr == null || ciIdArr.length == 0) {
			return null;
		}

		return this.confCiPropertyMapper.findByCiIdsAndPropertyId(ciIdArr,
				propertyId);
	}

	public List<ConfCiPropertyDTO> findDatailByCiId(String ciId) {
		return this.confCiPropertyMapper.findDetailByCiId(ciId);
	}

	public void deleteByCiIdAndProperties(String ciId,
			List<ConfCiProperty> properties) {
		confCiPropertyMapper.deleteByCiIdAndProperties(ciId, properties);
	}
}
